package com.tencent.mm.opensdk.channel;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.tencent.mm.opensdk.utils.Log;
import com.tencent.mm.opensdk.utils.TecentUtil;

/**
 * 通道信息
 */
public class ChannelInfo

{


    public String a;
    public String action;
    public String content;
    public long b;
    public Bundle bundle;

    public static boolean validateParam(Context paramContext, ChannelInfo parama) {
        if (paramContext == null) {
            Log.e("MicroMsg.SDK.MMessage", "send fail, invalid argument");
            return false;
        }
        if (TecentUtil.isEmpty(parama.action)) {
            Log.e("MicroMsg.SDK.MMessage", "send fail, action is null");
            return false;
        }
        String str1 = null;
        if (!TecentUtil.isEmpty(parama.a)) {
            str1 = parama.a + ".permission.MM_MESSAGE";
        }
        Intent localIntent = new Intent(parama.action);
        if (parama.bundle != null) {
            localIntent.putExtras(parama.bundle);
        }
        String str2 = paramContext.getPackageName();
        localIntent.putExtra("_mmessage_sdkVersion", 620756998);
        localIntent.putExtra("_mmessage_appPackage", str2);
        localIntent.putExtra("_mmessage_content", parama.content);
        localIntent.putExtra("_mmessage_support_content_type", parama.b);
        localIntent.putExtra("_mmessage_checksum", checksum(parama.content, 620756998, str2));
        paramContext.sendBroadcast(localIntent, str1);
        Log.d("MicroMsg.SDK.MMessage", "send mm message, intent=" + localIntent + ", perm=" + str1);
        return true;
    }

    public static byte[] checksum(String paramString1, int paramInt, String paramString2) {
        StringBuffer localStringBuffer = new StringBuffer();
        if (paramString1 != null) {
            localStringBuffer.append(paramString1);
        }
        localStringBuffer.append(paramInt);
        localStringBuffer.append(paramString2);
        localStringBuffer.append("mMcShCsTr");
        return TecentUtil.md5(localStringBuffer.toString().substring(1, 9).getBytes()).getBytes();
    }
}
